import { MICRO_SERVICE_ADMIN } from '~/constants/service-constant.ts'
import type { DeptReq, DeptResp } from '~/api/setting/model/dept.ts'

enum Api {
  QueryDeptTreeList = '/webservice/dept/queryDeptTreeList',
  CreateDept = '/webservice/dept/createDept',
  ModifyDept = '/webservice/dept/modifyDept',
  RemoveDeptById = '/webservice/dept/removeDeptById',
}

/**
 * 获取部门树
 */
export function queryDeptTreeListApi() {
  return usePost<DeptResp[], DeptReq>(MICRO_SERVICE_ADMIN + Api.QueryDeptTreeList)
}

/**
 * 创建部门
 * @param params 部门实体
 */
export function createDeptApi(params?: DeptReq) {
  return usePost<DeptResp, DeptReq>(MICRO_SERVICE_ADMIN + Api.CreateDept, params)
}

/**
 * 修改部门
 * @param params 部门实体
 */
export function modifyDeptApi(params?: DeptReq) {
  return usePost<DeptResp, DeptReq>(MICRO_SERVICE_ADMIN + Api.ModifyDept, params)
}

/**
 * 删除部门
 * @param params 部门实体，使用其中ID
 */
export function removeDeptByIdApi(params?: DeptReq) {
  return useGet<boolean>(MICRO_SERVICE_ADMIN + Api.RemoveDeptById, params)
}
